package net.lab1024.sa.admin.module.system.type.service;

import net.lab1024.sa.admin.module.system.type.Dao.TypeDao;
import net.lab1024.sa.admin.module.system.type.domain.TypeEntity;
import net.lab1024.sa.admin.module.system.type.domain.TypeVO;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class TypeService {
    @Resource
    private TypeDao TypeDao;

    public ResponseDTO<List<TypeEntity>> getTypeList(String key) {
        return ResponseDTO.ok(TypeDao.selectByKey(key));
    }
    public ResponseDTO<List<TypeVO>> getTypeVO(String key) {
        List<TypeEntity> typeEntities = TypeDao.selectByKey(key);
        List<TypeVO> typeVOS = new ArrayList<>();
        for (TypeEntity typeEntity : typeEntities) {
            TypeVO typeVO = new TypeVO();
            typeVO.setValue(typeEntity.getTypeId());
            typeVO.setText(typeEntity.getTypeName());
            typeVOS.add(typeVO);
        }
        return ResponseDTO.ok(typeVOS);
    }
}
